#include<cstdio>
const int maxn=100010;
int p[maxn+1],r[maxn+1];
int find(int x)
{
	int t;
	if(p[x]!=x)
	{
		t=p[x];
		p[x]=find(p[x]);
		r[x]=r[x]^r[t];
	}
	return p[x];
}
void merge(int a,int b,int pp,int qq)
{
	p[pp]=qq;
	r[pp]=~(r[a]^r[b]);
}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n,k;
		scanf("%d%d",&n,&k);
		for(int i=1;i<=n;i++){p[i]=i;r[i]=0;}
		for(int i=1;i<=k;i++)
		{
			char ch;
			int x,y;
			scanf("%c%c%d%d",&ch,&ch,&x,&y);
			int pp=find(x);
			int qq=find(y);
			if(ch=='A')
			{
				if(pp!=qq)printf("Not sure yet.\n");
				else
				{
					if(r[x]^r[y])printf("In different gangs.\n");
					else printf("In the same gang.\n");
				}
			}
			if(ch=='D')merge(x,y,pp,qq);
		}
	}
	return 0;
}

				
		
